<template>
  <Table v-bind="tableOpts" v-on="tableEvent">
    <template #operator>
      <div class="operator-wrap">
        <updateFinance ref="updateFinanceRef" @change="fetchCurrentTable" />
      </div>
    </template>
  </Table>
</template>

<script>
import tableMixins from "@/mixins/tableMixins.vue";
import dayjs from "dayjs";
import updateFinance from "../components/updateFinance.vue";
export default {
  name: "FinanceReject",
  mixins: [tableMixins],
  components: {
    updateFinance,
  },
  data() {
    return {
      apiName: "newFinanceRejectList",
      form: {
        id: {
          tag: "el-input",
          label: "订单ID",
          value: "",
          props: {
            clearable: true,
            placeholder: "请输入订单ID",
          },
        },
        storeName: {
          tag: "el-input",
          label: "订单名称",
          value: "",
          props: {
            clearable: true,
            placeholder: "请输入订单名称",
          },
        },
      },
    };
  },
  computed: {},
  methods: {
    handleAction(opts, row) {
      const { id, orderId, storeName: name } = row;
      let ref = null;
      ref = this.$refs[opts];
      ref && ref.showDialog(opts, row);
    },
    formatData(res) {
      this.total = res?.total || 0;
      this.dataSource = (res?.data || res || []).map((e) => {
        if (e.updatedAt)
          e.updatedTime = dayjs(e.updatedAt).format("YYYY-MM-DD HH:mm:ss");
        if (e.createdAt) {
          e.createdTime = dayjs(e.createdAt).format("YYYY-MM-DD HH:mm:ss");
        }
        if (e?.orderRecord) {
          const keys = ["storeName", "deliveryDate", "address", "customPhone"];
          keys.forEach((k) => {
            e[k] = e?.orderRecord[k];
          });
        }
        if (e[e.type]) {
          const keys = [
            "departFee",
            "departImg",
            "installFee",
            "installImg",
            "hotelFee",
            "hotelImg",
            "foodFee",
            "foodImg",
            "trafficFee",
            "trafficImg",
          ];
          keys.forEach((k) => {
            e[k] = e[e.type][k];
          });
        }
        return e;
      });
    },
  },
};
</script>

<style lang="less" scoped></style>
